﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;

namespace Bxas.Generator
{
    /// <summary>
    /// Summary description for Category.
    /// </summary>
    public class Project
    {

        private string id;
        private string name;
        private string conStr;
        private string fileName;
        private string directoryName;
        public Project()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public string ID
        {
            get { return id; }
            set { id = value; }
        }
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public string ConStr
        {
            get { return conStr; }
            set { conStr = value; }
        }
        public string FileName
        {
            get { return fileName; }
            set { fileName = value; }
        }
        public string DirectoryName
        {
            get { return directoryName; }
            set { directoryName = value; }
        }
    }
    public class ProjectList
    {
        public static Project GetProject(string id)
        {
            DataRow iDr = null;
            iDr = XMLProject.Select(id);
            Project cat = null;
            if (iDr != null)
            {
                cat = new Project();
                cat.ID = iDr[0] != DBNull.Value ? iDr[0].ToString() : string.Empty; ;
                cat.Name = iDr[1] != DBNull.Value ? iDr[1].ToString() : string.Empty;
                cat.ConStr = iDr[2] != DBNull.Value ? iDr[2].ToString() : string.Empty;
                cat.FileName = iDr[3] != DBNull.Value ? iDr[3].ToString() : string.Empty;
                cat.DirectoryName = iDr[4] != DBNull.Value ? iDr[4].ToString() : string.Empty;
            }
            return cat;
        }
        public static IList GetProjectList()
        {
            return XMLProject.SelectAll();
        }

        public static void UpdateProject(Project cat)
        {
            XMLProject.Update(cat.ID, cat.Name,cat.ConStr,cat.FileName,cat.DirectoryName);
        }

        public static void UpdateProject(Project cat, string newid)
        {
            XMLProject.Update(cat.ID, newid, cat.Name, cat.ConStr, cat.FileName, cat.DirectoryName);
        }

        public static void InsertProject(Project cat)
        {
            XMLProject.Insert(cat.ID, cat.Name, cat.ConStr, cat.FileName, cat.DirectoryName);
        }

        public static void DeleteProject(string Id)
        {
            XMLProject.Delete(Id);
        }
    }
}
